package com.cf.rpsm_admin.Pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class ResponsePojo<T> {
    @ApiModelProperty(value= "响应的数据")
    private T data;
    @ApiModelProperty(value= "响应的说明信息")
    private String message;
    @ApiModelProperty(value= "响应状态码，1：成功，2：失败")
    private int code;

    public ResponsePojo(T t) {
        this.data = t;
        this.code = 1;
        this.message= "";
    }

    public int getCode(){
        return this.code;
    }

    public void setCode(int code){
        this.code = code;
    }

    public String getMessage(){
        return this.message;
    }

    public void setMessage(String message){
        this.message = message;
    }

    private ResponsePojo(T t, String message, int code) {
        this.data = t;
        this.message = message;
        this.code = code;
    }

    public static <T> ResponsePojo<T> success(T t){
 return new ResponsePojo<>(t);
    }


    public static <T> ResponsePojo<T> fail(T t, String message){
        return new ResponsePojo<>(t, message, 2);
    }
}
